package com.example.ass.mapper;




import com.example.ass.pojo.Article;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ArticleMapper {
    @Select("SELECT * FROM article")
    List<Article> findAll();

    @Select("SELECT * FROM article WHERE id = #{id}")
    Article findById(Integer id);

    @Insert("INSERT INTO article (title, content, cover_img, state, category_id, create_user, create_time, update_time) " +
            "VALUES (#{title}, #{content}, #{coverImg}, #{state}, #{categoryId}, #{createUser}, #{createTime}, #{updateTime})")
    void insert(Article article);

    @Update("UPDATE article SET title = #{title}, content = #{content}, cover_img = #{coverImg}, " +
            "state = #{state}, category_id = #{categoryId}, create_user = #{createUser}, " +
            "create_time = #{createTime}, update_time = #{updateTime} WHERE id = #{id}")
    void update(Article article);

    @Delete("DELETE FROM article WHERE id = #{id}")
    void delete(Integer id);
}